#include "pid_app.h"
#include "user_usart.h"

//设置目标值
void debug_pid_set_target(uint8_t selec, float target)
{
	if(selec == 1)
	{
		pid_set_target(&r_speed_pid, target);		
	}
	else if(selec == 2)
	{
		pid_set_target(&l_speed_pid, target);
	}
	else if(selec == 3)
	{
		pid_set_target(&angle_pid, target);
	}
}

//设置pid参数
void debug_pid_set_argut(uint8_t selec, float p, float i, float d)
{
	if(selec == 1)
	{
		pid_set_argument(&r_speed_pid, p, i, d);
	}
	else if(selec == 2)
	{
		pid_set_argument(&l_speed_pid, p, i, d);
	}
	else if(selec == 3)
	{
		pid_set_argument(&angle_pid, p, i, d);
	}
}

//获取pid值
void debug_pid_show_argut(uint8_t selec)
{
	if(selec == 1)
	{
		debug_printf("\r\nkp: %.2f  ki: %.2f  kd: %.2f\r\n", r_speed_pid.kp, r_speed_pid.ki, r_speed_pid.kd);
	}
	else if(selec == 2)
	{
		debug_printf("\r\nkp: %.2f  ki: %.2f  kd: %.2f\r\n", l_speed_pid.kp, l_speed_pid.ki, l_speed_pid.kd);
	}
	else if(selec == 3)
	{
		debug_printf("\r\nkp: %.2f  ki: %.2f  kd: %.2f\r\n", angle_pid.kp, angle_pid.ki, angle_pid.kd);
	}
}

//切换角度环使能状态
void angle_pid_switch(uint8_t selec)
{
	if(selec == 1)
	{
		pid_enable(&angle_pid);
	}
	else if(selec == 0)
	{
		pid_disable(&angle_pid);
	}
}

